<?php
namespace Cyfy;

/**
 * Custom calls.
 *
 * Class used for custom calls through /call.php, quite similar to Ajax class.
 * The difference is that print content themselves.
 *
 * @category cyfy
 * @author Dandelion <dandelion8888@gmail.com>
 * @version 0.1
 */ 
class Call
{
    /**
     * Method, which processes the query. Calls method $module :: call($call)
     *
     * @param string Module to be called
     * @param string Callback name
     * @return mixed Callback result, when method found, otherwise error message.
     */ 
    static function process($module, $call)
    {	
        $class = "\Cyfy\Modules\\" . $module . "\Module";
        if(file_exists(classToPath($class) . ".php"))
        {
            if(method_exists($class, "call"))
            {
                return $class :: call($call);		
            }
        }
        return "Called method not found.";
    }
}
